home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacGames Sampler
/
PHT MacGames Bundle.iso
/
MacSource Folder
/
Samples from the CD
/
C and C++
/
sesame C ƒ
/
~ASAMPLE.INC
next >
Wrap
Text File
|
1986-08-31
|
9KB
|
205 lines
/* INCLUDE FILE FOR SAMPLE C PROGRAM */
/* We start with a general description of how to use the compiler */
/* That is followed by the actual #define statements for the sample */
/* program */
/* WHAT IS SESAME C */
/* Sesame C is a development system for the Macintosh. */
/* It includes a 68000 assembler and a C compiler. */
/* The 68000 assembler is almost as good as you can get anywhere. */
/* The only thing it lacks is macros. The C compiler is a subset */
/* of what a full C has. The most notable lacks are no floating */
/* point arithmetic, no structures and no multidimensional arrays. */
/* Of course, these omissions can be got around by clever programming. */
/* In the future, we may add them. We mostly developed this */
/* development system because we were 1) curious about cracking the */
/* Mac environment, 2) wanted to be able to write real stand-alone */
/* applications, 3) frustrated by the expense of buying one of the */
/* main line development systems. It's design then reflects our */
/* needs/desires for getting into development. You should find it */
/* a powerful, inexpensive tool */
/* WHAT YOU NEED */
/* This compiler does most everything, but we do assume a few things. */
/* We assume you have knowledge of C and 68000 assembler (at least one */
/* of them) or that you want to learn. We assume you have access */
/* to a book describine the Macintosh toolbox routines. */
/* Lastly, we assume you don't want to pay $200-500 for the */
/* opportunity of beating up in C on the Macintosh. */
/* HOW TO COMPILE */
/* To compile the sample program simply select the C COMPILE... command */
/* from the menu and select ASAMPLE.C. The include file (as is so for */
/* all include files) must be in the same folder as the source file you */
/* you are compiling (assuming you are using HFS, of course). You */
/* will be prompted via dialog for a name for the object file that */
/* is created. You should put this in a folder with all your other */
/* object or object libraries. After compiling the sample, you can */
/* make an application with it by selecting LINK & BUILD... from the */
/* menu. There should be a file with link instructions in the same */
/* folder with your object files. We have supplied one called */
/* ASAMPLE.LNK. Assuming you have use the default names to compile */
/* object, this will make a real Macintosh program. */
/* ABOUT LIBRARIES */
/* One of our neat features is a library system for holding the object. */
/* Without libraries even using the HFS you would find your object files */
/* multiplying rapidly. Libraries can be used to store any amount of */
/* object. To put things into them either use the ADD... command from the */
/* Library menu, or select use library to direct all your assemblies */
/* to the selected library. If you blow it and put something into a */
/* library by mistake you can delete individual members from the library */
/* A friendly warning: no checking is performed to keep out duplicate */
/* entries, so if you compile two different files with the same entry) */
/* names (subroutine names for the uninitiated) you can get odd results */
/* A friendly trick: if you want to know what is in a library select */
/* EXTRACT... from the Library menu and get a listing. Just cancel, if */
/* you don't want to extract a copy of an object file. */
/* Libraries can be used interchangably with regular object files. Only */
/* the actual entries that are needed will be loaded into your application.*/
/* TECHNICAL NOTES */
/* We have only two variable types, long integer (32 bit, 4 byte) and */
/* char (8 bit, 1 byte). Of couse, we have arrays and pointers too but */
/* only with these two basic types of variables. All arithmetic is */
/* signed 32 bit arithmetic (more or less). We have no floating point */
/* except by using the toolbox stuff explicitly. This means we are */
/* quite fast by the way. */
/* We can access any toolbox routine that is stack based by using the */
/* TRAP feature of the compiler. The form of TRAP calls is: */
/* TRAP(trapnumber,arg1,arg2,arg3...); The trap number is the */
/* hex value for the trap (for example, 0XA9D5 is the hex trap number */
/* for TECUT. Each argument following the trap number must be in the */
/* same order as show for the toolbox routines in any of the basic */
/* books on the Macintosh toolbox. Each argument should be followed */
/* by a :B, :W, or :L to indicate if only a byte, word, or long word */
/* is to be passed. If you omit the size reference, the argument will */
/* be passed as a long word. If the trap returns a value as a function, */
/* you must follow the word TRAP with a :B, :W, or :L to indicate the */
/* size of the return value. There are plenty of examples of all */
/* kinds of TRAP calls in the ASAMPLE.C program. Another friendly */
/* warning: Be sure you do the argument and trapnumbers correctly. */
/* The toolbox routines are quite powerful and bad values can give */
/* bizarre results that are hard to debug. */
/* Non-stacked based routines are a different matter. Generally, these */
/* need to be handled in assembler. Some have already been provided, such */
/* as flushevents and sethandlesize. In the case of file IO, we have */
/* created a generic routine PBIO that gives you access to all the */
/* parameter block based routines. By the way, when creating your */
/* own assembler routines, be sure to have the entry names begin with */
/* _ (an underbar). This is way the C compiler calls all routines. */
/* One oddity, we require that you declare function arguments in */
/* the same order that they are listed in the function. For example, */
/* readfile(filename,volref) */
/* char filename[]; */
/* int volref; */
/* is the correct way to declare this function. Reversing the */
/* filename and volref lines, would not work properly */
/* LAST OF ALL... ENJOY YOURSELF. Send us any ideas you have for */
/* improvements. We are working on such things as a library of */
/* toolbox calls, structures, multidimernsional arrays, etc but */
/* welcome clever ideas. */
/* #DEFINES */
/* One of the things registered owners get is a set of #defines for */
/* the various Macintosh toolbox routines grouped by function */
#define INITCURSOR 0XA850
#define INITPORT 0XA86D
#define INITGRAF 0XA86E
#define INITFONTS 0XA8FE
#define INITWINDOWS 0XA912
#define INITMENUS 0XA930
#define INITDIALOGS 0XA97B
#define INITRESOURCES 0XA995
#define TEINIT 0XA9CC
#define NEWWINDOW 0XA913
#define DISPOSEWINDOW 0XA914
#define TEXTFONT 0XA887
#define TEXTSIZE 0XA88A
#define GETFONTINFO 0XA88B
#define MOVETO 0XA893
#define CLOSEWINDOW 0XA92D
#define SETPORT 0XA873
#define BEGINUPDATE 0XA922
#define ENDUPDATE 0XA923
#define DRAWCHAR 0XA883
#define SETRECT 0XA8A7
#define SCROLLRECT 0XA8EF
#define GETNEXTEVENT 0XA970
#define MENUKEY 0XA93E
#define MENUSELECT 0XA93D
#define HILITEMENU 0XA938
#define NEWMENU 0XA931
#define APPENDMENU 0XA933
#define INSERTMENU 0XA935
#define DRAWMENUBAR 0XA937
#define PTINRECT 0XA8AD
#define TENEW 0XA9D2
#define TEKEY 0XA9DC
#define TECUT 0XA9D6
#define TECOPY 0XA9D5
#define TEDELETE 0XA9D7
#define TEPASTE 0XA9DB
#define TESETSELECT 0XA9D1
#define TEIDLE 0XA9DA
#define TECLICK 0XA9D4
#define GLOBALTOLOCAL 0XA871
#define TEACTIVATE 0XA9D8
#define TEDEACTIVATE 0XA9D9
#define TEUPDATE 0XA9D3
#define FINDWINDOW 0XA92C
#define NEWCONTROL 0XA954
#define FINDCONTROL 0XA96C
#define TRACKCONTROL 0XA968
#define SETCTLVALUE 0XA963
#define GETCTLVALUE 0XA960
#define GETCTLMAX 0XA962
#define SETCTLMAX 0XA965
#define STILLDOWN 0XA973
#define GETMOUSE 0XA972
#define TESTCONTROL 0XA966
#define HILITECONTROL 0XA95D
#define TESCROLL 0XA9DD
#define TECALTEXT 0XA9D0
#define DRAWCONTROLS 0XA969
#define TEDISPOSE 0XA9CD
#define GETWTITLE 0XA919
#define appleid 32
#define fileid 33
#define editid 34
#define eol 13
#define pagelines 26 /* monaco lines per window of viewrect size */
/* extern declarations would normally go here */
/* for example */
/* extern char seventrec[16]; */
/* extern int tehnd,windptr; */
/* extern int applemenu, filemenu, editmenu; */
/* There aren't any here, because the application fits into */
/* one file. Note, there aren't any static variables */
/* These global externals can total up to 32k */